<?php
//print_r($posts)
?>

<h1>Blog posts</h1>
<table>
    <tr>
        <th>Id</th>
        <th>Title</th>
        <th>Created</th>
        <th>Edit</th>
        <th>Delete</th>
    </tr>

    <!-- Here is where we loop through our $posts array, printing out post info -->

    <?php foreach ($posts as $post): ?>
    <tr>
        <td><?php echo $post['Post']['id']; ?></td>
        <td><?php echo $this->Html->link($post['Post']['title'],array('controller' => 'posts', 'action' => 'readpost', $post['Post']['id'])); ?></td>
        <td><?php echo $post['Post']['created']; ?></td>
        <td><?php echo $this->Html->link('edit post',array('controller' => 'posts', 'action' => 'updatepost', $post['Post']['id'])) ?></td>
        <td><?php echo $this->Form->postLink('Delete', array('action' => 'deletepost', $post['Post']['id']), array('confirm' => 'Are you sure?')); ?></td>
    </tr>
    <?php endforeach; ?>

</table>

<p><?php echo $this->Html->link("nuevo post",array('controller' => 'posts', 'action' => 'createpost', null)) ?></p>